package nl.hanze.designpatterns.mvc.controller;

import java.awt.event.ActionEvent;

import nl.hanze.designpatterns.mvc.model.MainModel;
import nl.hanze.designpatterns.mvc.view.LoginGui;
import nl.hanze.designpatterns.mvc.view.MainAppGui;
import nl.hanze.designpatterns.mvc.view.ProfileView;
import nl.hanze.designpatterns.mvc.view.QenAView;
import nl.hanze.designpatterns.mvc.view.ShowTicketsView;

public class MainAppGuiController extends Controller {

	private MainAppGui mainAppGui;
	private MainModel model;
	
	public MainAppGuiController(MainAppGui mainAppGui, MainModel model){
		init(mainAppGui, model);
	}
	
	private void init(MainAppGui mainAppGui, MainModel model){
		this.mainAppGui = mainAppGui;
		this.model = model;
	}
	
	private void exitApp(){
		System.exit(0);
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		System.out.println(e.getActionCommand());
		try{
			switch(e.getActionCommand()){
			case"exit":
				this.exitApp();
				break;
			case"showTicketsView":
				mainAppGui.changeViews(new ShowTicketsView(this.model));
				break;
			case"showProfile":
				mainAppGui.changeViews(new ProfileView());
				break;
			case"logout":
				this.mainAppGui.setVisible(false);
				this.mainAppGui.dispose();
				this.model.getLoginModel().setLogin(null);
				new LoginGui(model);
				break;
			case"display_qena":
				mainAppGui.changeViews(new QenAView());
			case"help":
				System.out.println("some popup");
				break;
			default:
				throw new Exception("Unknown Command");
			}
		}catch(Exception ex){
			ex.printStackTrace();
		}
	}
}
